package com.example.algorithm.sorts;

public class BubbleSort {
    public static void main(String[] args) {

        int[] nums = {3,5,7,4,2,9,1,3};
        bubbleSort(nums);

        for (int num : nums) {
            System.out.print(num + ",");
        }

    }

    public static void bubbleSort(int[] nums) {
        int tmp = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            for (int j = 0; j<nums.length - i -1; j++){
                if (nums[j] > nums[j + 1]) {
                    tmp = nums[j];
                    nums[j] = nums[j + 1];
                    nums[j + 1] = tmp;
                }
            }
        }

    }
}
